<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>
<!--
	Copyright (C) 2006,2007 NewAsp.Net. All rights reserved.
	Written by newasp.net Lao Mi
	Web: http://www.newasp.net/,http://www.newasp.cn/
	Email: newasp@163.com
-->
<xsl:template match="/">
<xsl:element name="agent">
<xsl:attribute name="ip"><xsl:value-of select="xml/@ip"/></xsl:attribute>
<xsl:attribute name="lockip"><xsl:call-template name="checkip"/></xsl:attribute>
</xsl:element>
</xsl:template>
	<xsl:template name="checkip">
		<xsl:variable name="number1" select="substring-before(xml/@ip,'.')"></xsl:variable>
		<xsl:variable name="number2" select="substring-before(substring-after(xml/@ip,'.'),'.')"></xsl:variable>
		<xsl:variable name="number3" select="substring-before(substring-after(substring-after(xml/@ip,'.'),'.'),'.')"></xsl:variable>
		<xsl:variable name="number4" select="substring-after(substring-after(substring-after(xml/@ip,'.'),'.'),'.')"></xsl:variable>
		<xsl:choose>
		<xsl:when test="/xml/lockip[(@number1=$number1 or @number1='*') and (@number2=$number2 or @number2='*') and (@number3=$number3 or @number3='*') and (@number4=$number4 or @number4='*')]">1</xsl:when>
		<xsl:otherwise>
		<xsl:choose>
		<xsl:when test="xml/@actforip!=''"><xsl:call-template name="checkip1"/></xsl:when>
		<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
		</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="checkip1">
		<xsl:variable name="number1" select="substring-before(xml/@actforip,'.')"></xsl:variable>
		<xsl:variable name="number2" select="substring-before(substring-after(xml/@actforip,'.'),'.')"></xsl:variable>
		<xsl:variable name="number3" select="substring-before(substring-after(substring-after(xml/@actforip,'.'),'.'),'.')"></xsl:variable>
		<xsl:variable name="number4" select="substring-after(substring-after(substring-after(xml/@actforip,'.'),'.'),'.')"></xsl:variable>
		<xsl:choose>
		<xsl:when test="/xml/lockip[(@number1=$number1 or @number1='*') and (@number2=$number2 or @number2='*') and (@number3=$number3 or @number3='*') and (@number4=$number4 or @number4='*')]">1</xsl:when>
		<xsl:otherwise>0</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>